package ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

class ThreadpoolDemo4 {
    public static void main(String[] args) {

        //创建一个默认线程池
        ExecutorService pool = Executors.newCachedThreadPool();

        //提交一个任务
        pool.submit(
                ()->{
                    for (int i = 0; i < 100; i++) {
                        System.out.println("任务1");
                    }
                }
        );

        pool.submit(
                ()->{
                    for (int i = 0; i < 100; i++) {
                        System.out.println("任务2");
                    }
                }
        );

        pool.shutdown();

    }
}
